import request from '../utils/request'
const baseUrl = 'api'

// 登录接口
export function loginUrl (data) {
  return request({
    url: `${baseUrl}/login`,
    method: 'post',
    data
  })
}

// 获取用户信息接口
export function getUserInfo () {
  return request({
    url: `${baseUrl}/user_info`,
    method: 'get'
  })
}

// 部门列表
export const departmentList = query => {
  return request({
    url: `${baseUrl}/department/list`,
    method: 'get',
    params: query
  })
}

// 所有用户列表，前端组件使用
export function staffAll () {
  return request({
    url: `${baseUrl}/staff/all`,
    method: 'get'
  })
}

// 所有部门列表，前端组件使用
export function departmentAll () {
  return request({
    url: `${baseUrl}/department/all`,
    method: 'GET'
  })
}

// 所有法人主体，全部是已生效的
export function companyAll () {
  return request({
    url: `${baseUrl}/company/all`,
    method: 'GET'
  })
}

// 新增部门信息
export function addDepartment (data) {
  return request({
    url: `${baseUrl}/department/create`,
    method: 'POST',
    data
  })
}

// 更新部门信息
export function updateDepartment (data) {
  return request({
    url: `${baseUrl}/department/update`,
    method: 'POST',
    data
  })
}

// 修改部门状态
export function changeDepartmentStatus (data) {
  return request({
    url: `${baseUrl}/department/change_status`,
    method: 'POST',
    data
  })
}

// 删除部门
export function deleteDepartment (data) {
  return request({
    url: `${baseUrl}/department/delete`,
    method: 'POST',
    data
  })
}

// 导出部门 excel
export function exportDepartment (query) {
  return request({
    url: `${baseUrl}/department/export`,
    method: 'get',
    params: query
  })
}

// 组织架构树
export function departmentTree (query) {
  return request({
    url: `${baseUrl}/department/tree`,
    method: 'get',
    params: query
  })
}

// 员工列表
export function staffList (query) {
  return request({
    url: `${baseUrl}/staff/list`,
    method: 'post',
    data: query
  })
}

// 更新员工信息
export function updateStaff (params) {
  return request({
    url: `${baseUrl}/staff/update`,
    method: 'post',
    data: params
  })
}

// 禁用
export function deleteStaff (params) {
  return request({
    url: `${baseUrl}/staff/delete`,
    method: 'delete',
    params
  })
}

// 员工辞职申请列表
export function resignList (query) {
  return request({
    url: `${baseUrl}/resign/list`,
    method: 'GET',
    params: query
  })
}

export const fetchData = query => {
  return request({
    url: './table.json',
    method: 'get',
    params: query
  })
}
